#!/bin/bash


if [ `id -u` -ge 1000 ];then
  echo "usage: sudo bash $0 args..."
  exit 1
fi


#export DIR_NOT_CHECK_MOUNTPOINT=true
DIR_NOT_CHECK_MOUNTPOINT=false
if [ "x$1" == "xnodisk" ];then
    DIR_NOT_CHECK_MOUNTPOINT=true
fi


BinHome="/opt/server.lan"
MntHome="/mnt/server.lan"
TmpHome="/tmp/server.lan"

export DIR_NOT_CHECK_MOUNTPOINT
export BinHome MntHome TmpHome 

(
    cd  "$(dirname "$0")"

    for i in install/*.rc;do
      echo "[-i-] source $i"
      . "$i"
      echo ""
    done

    for i in install/*.sh;do
      echo "[-i-] run bash $i"
      sudo bash "$i"
      echo " ===> exit=$?
      "
    done

    echo "

[INFO]run cmd below to install services : 
    sudo bash '$(dirname "$0")/service_images/install.sh'

"

)


(
  exit 0
  uname -m
  ARCH=""
  if uname -m | grep -F "x86_64";then
    ARCH="amd64"
  elif uname -m | grep -F "x86";then
    ARCH="x86"
  elif uname -m | grep -F "armv7l";then
    ARCH="armhf"
  elif uname -m | grep -F "arm64";then
    ARCH="arm64"
  elif uname -m | grep -F "aarch64";then
    ARCH="arm64"
  else
    echo "[E] unknown ARCH , exit"
    exit 1
  fi
  echo "[INFO] ARCH=$ARCH"
)

